@(id: Long, computerForm: Form[Computer], companies: Map[String, String])(implicit request: Http.Request, messages: play.i18n.Messages)

@import helper._

@implicitField: FieldConstructor = @{ FieldConstructor(tags.forms.field_constructor.render) }

@main {

    <h1 class="my-3" id="page-title">Edit computer</h1>

    @form(routes.HomeController.update(id)) {

        @CSRF.formField
        <div class="row">
            <div class="col-md-3 mb-3">
            @inputText(computerForm("name"), Symbol("_label") -> "Computer name", Symbol("_help") -> "")
            </div>
        </div>
        <div class="row">
            <div class="col-md-3 mb-3">
            @inputDate(computerForm("introduced"), Symbol("_label") -> "Introduced date", Symbol("_help") -> "")
            </div>
        </div>
        <div class="row">
            <div class="col-md-3 mb-3">
            @inputDate(computerForm("discontinued"), Symbol("_label") -> "Discontinued date", Symbol("_help") -> "")
            </div>
        </div>

        <div class="row">
            <div class="col-md-3 mb-3">
            @select(
                computerForm("company.id"),
                options(companies),
                Symbol("_label") -> "Company", Symbol("_default") -> "-- Choose a company --",
                Symbol("_showConstraints") -> false
            )
            </div>
        </div>

        <div class="actions">
            <button class="btn btn-success" type="submit">Save this computer</button>
            <span class="mx-2">or</span>
            <a href="@routes.HomeController.list()" id="add" class="btn btn-light" role="button">Cancel</a>
        </div>

    }

    @form(routes.HomeController.delete(id), Symbol("class") -> "top-right") {
        @CSRF.formField
        <button class="btn btn-danger" type="submit">Delete this computer</button>
    }

}
